using cframework_xlua;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class LaunchHotUpdate : BaseLaunchHotUpdate
{
    public GameObject loadingImg;
    public Text errorText;

    protected new IEnumerator Start()
    {
        loadingImg.gameObject.SetActive(true);

        var e = base.Start().WithResult();
        yield return e;

        var state = (State)e.Current;
        switch(state)
        {
            case State.StartGameSuccess:
                {
                    UnityEngine.SceneManagement.SceneManager.UnloadSceneAsync(this.gameObject.scene);
                }
                break;
            case State.StartHotUpdateSuccess:
                {
                    this.gameObject.SetActive(false);
                }
                break;
            default:
                {
                    Debug.LogError("Launch Failed: " + state);

                    errorText.text = "Launch Failed: " + state;
                    loadingImg.gameObject.SetActive(false);

                    break;
                }
        }
    }
}
